import request from "@/utils/request";

export const blogApi = {
  // 获取博客列表
  getBlogs(params) {
    return request({
      url: "/api/blogs",
      method: "get",
      params,
    });
  },

  // 获取单个博客详情
  getBlog(id) {
    return request({
      url: `/api/view/${id}`,
      method: "get",
    });
  },

  // 创建博客
  createBlog(data) {
    return request({
      url: "/api/blogs",
      method: "post",
      data,
    });
  },

  // 更新博客
  updateBlog(id, data) {
    return request({
      url: `/api/blogs/${id}`,
      method: "put",
      data,
    });
  },

  // 删除博客（逻辑删除）
  deleteBlog(id) {
    return request({
      url: `/api/delete/${id}`,
      method: "delete",
    });
  },

  // 永久删除博客
  deleteBlogPermanent(id) {
    return request({
      url: `/api/blogs/${id}/permanent`,
      method: "delete",
    });
  },

  // 批量删除博客
  batchDeleteBlogs(ids) {
    return request({
      url: "/api/blogs/batch",
      method: "delete",
      data: { ids },
    });
  },

  // 批量永久删除博客
  batchDeleteBlogsPermanent(ids) {
    return request({
      url: "/api/blogs/batch/permanent",
      method: "delete",
      data: { ids },
    });
  },

  // 批量发布博客
  batchPublishBlogs(ids) {
    return request({
      url: "/api/blogs/batch/publish",
      method: "put",
      data: { ids },
    });
  },

  // 批量切换评论状态
  batchToggleCommentStatus(ids) {
    return request({
      url: "/api/blogs/batch/comment-status",
      method: "put",
      data: { ids },
    });
  },

  // 批量切换置顶状态
  batchToggleTopStatus(ids) {
    return request({
      url: "/api/blogs/batch/top-status",
      method: "put",
      data: { ids },
    });
  },
};
